package com.crr.mall.common.exception;

import com.crr.mall.common.bean.ResultBean;
import com.crr.mall.common.utils.BaseController;


import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLSyntaxErrorException;


/**
 * 全局异常处理
 */
@RestControllerAdvice(basePackages = "com.crr") //异常的增强处理
public class GlobedException extends BaseController {
    @ExceptionHandler(ValidateException.class)
    public ResultBean handlerValideException(ValidateException e){
        return fail("后端验证异常",e.getMessage());
    }
    @ExceptionHandler(SQLSyntaxErrorException.class)
    public ResultBean handlersqlException(){
        return fail("sql语句错误");
    }
}
